\doxysection{user\+\_\+lib.\+h}
\hypertarget{user__lib_8h_source}{}\label{user__lib_8h_source}\index{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/modules/algorithm/user\_lib.h@{C:/Users/ASUS/Desktop/dm-\/ctrlH7-\/balance-\/9025test/modules/algorithm/user\_lib.h}}
\mbox{\hyperlink{user__lib_8h}{Go to the documentation of this file.}}
\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ }
\DoxyCodeLine{00013\ \textcolor{preprocessor}{\#ifndef\ \_USER\_LIB\_H}}
\DoxyCodeLine{00014\ \textcolor{preprocessor}{\#define\ \_USER\_LIB\_H}}
\DoxyCodeLine{00015\ }
\DoxyCodeLine{00016\ \textcolor{preprocessor}{\#include\ "{}stdint.h"{}}}
\DoxyCodeLine{00017\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{main_8h}{main.h}}"{}}}
\DoxyCodeLine{00018\ \textcolor{preprocessor}{\#include\ "{}cmsis\_os.h"{}}}
\DoxyCodeLine{00019\ \textcolor{preprocessor}{\#include\ "{}\mbox{\hyperlink{stm32h723xx_8h}{stm32h723xx.h}}"{}}}
\DoxyCodeLine{00020\ \textcolor{preprocessor}{\#include\ "{}arm\_math.h"{}}}
\DoxyCodeLine{00021\ }
\DoxyCodeLine{00022\ }
\DoxyCodeLine{00023\ \textcolor{preprocessor}{\#ifndef\ user\_malloc}}
\DoxyCodeLine{00024\ \textcolor{preprocessor}{\#ifdef\ \_CMSIS\_OS\_H}}
\DoxyCodeLine{00025\ \textcolor{preprocessor}{\#define\ user\_malloc\ pvPortMalloc}}
\DoxyCodeLine{00026\ \textcolor{preprocessor}{\#else}}
\DoxyCodeLine{00027\ \textcolor{preprocessor}{\#define\ user\_malloc\ malloc}}
\DoxyCodeLine{00028\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00029\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00030\ }
\DoxyCodeLine{00031\ \textcolor{preprocessor}{\#define\ msin(x)\ (arm\_sin\_f32(x))}}
\DoxyCodeLine{00032\ \textcolor{preprocessor}{\#define\ mcos(x)\ (arm\_cos\_f32(x))}}
\DoxyCodeLine{00033\ }
\DoxyCodeLine{00034\ \textcolor{keyword}{typedef}\ \mbox{\hyperlink{structarm__matrix__instance__f32}{arm\_matrix\_instance\_f32}}\ mat;}
\DoxyCodeLine{00035\ \textcolor{comment}{//\ 若运算速度不够,可以使用q31代替f32,但是精度会降低}}
\DoxyCodeLine{00036\ \textcolor{preprocessor}{\#define\ MatAdd\ arm\_mat\_add\_f32}}
\DoxyCodeLine{00037\ \textcolor{preprocessor}{\#define\ MatSubtract\ arm\_mat\_sub\_f32}}
\DoxyCodeLine{00038\ \textcolor{preprocessor}{\#define\ MatMultiply\ arm\_mat\_mult\_f32}}
\DoxyCodeLine{00039\ \textcolor{preprocessor}{\#define\ MatTranspose\ arm\_mat\_trans\_f32}}
\DoxyCodeLine{00040\ \textcolor{preprocessor}{\#define\ MatInverse\ arm\_mat\_inverse\_f32}}
\DoxyCodeLine{00041\ \textcolor{keywordtype}{void}\ MatInit(mat\ *m,\ uint8\_t\ row,\ uint8\_t\ col);}
\DoxyCodeLine{00042\ }
\DoxyCodeLine{00043\ \textcolor{comment}{/*\ boolean\ type\ definitions\ */}}
\DoxyCodeLine{00044\ \textcolor{preprocessor}{\#ifndef\ TRUE}}
\DoxyCodeLine{00045\ \textcolor{preprocessor}{\#define\ TRUE\ 1\ }\textcolor{preprocessor}{}}
\DoxyCodeLine{00046\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00047\ }
\DoxyCodeLine{00048\ \textcolor{preprocessor}{\#ifndef\ FALSE}}
\DoxyCodeLine{00049\ \textcolor{preprocessor}{\#define\ FALSE\ 0\ }\textcolor{preprocessor}{}}
\DoxyCodeLine{00050\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00051\ }
\DoxyCodeLine{00052\ \textcolor{comment}{/*\ circumference\ ratio\ */}}
\DoxyCodeLine{00053\ \textcolor{preprocessor}{\#ifndef\ PI}}
\DoxyCodeLine{00054\ \textcolor{preprocessor}{\#define\ PI\ 3.14159265354f}}
\DoxyCodeLine{00055\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00056\ }
\DoxyCodeLine{00057\ \textcolor{preprocessor}{\#define\ VAL\_LIMIT(val,\ min,\ max)\ \(\backslash\)}}
\DoxyCodeLine{00058\ \textcolor{preprocessor}{\ \ \ \ do\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00059\ \textcolor{preprocessor}{\ \ \ \ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00060\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ if\ ((val)\ <=\ (min))\ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00061\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00062\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ (val)\ =\ (min);\ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00063\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00064\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ else\ if\ ((val)\ >=\ (max))\ \(\backslash\)}}
\DoxyCodeLine{00065\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00066\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ (val)\ =\ (max);\ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00067\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \}\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00068\ \textcolor{preprocessor}{\ \ \ \ \}\ while\ (0)}}
\DoxyCodeLine{00069\ }
\DoxyCodeLine{00070\ \textcolor{preprocessor}{\#define\ ANGLE\_LIMIT\_360(val,\ angle)\ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00071\ \textcolor{preprocessor}{\ \ \ \ do\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00072\ \textcolor{preprocessor}{\ \ \ \ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00073\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ (val)\ =\ (angle)\ -\/\ (int)(angle);\ \(\backslash\)}}
\DoxyCodeLine{00074\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ (val)\ +=\ (int)(angle)\ \%\ 360;\ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00075\ \textcolor{preprocessor}{\ \ \ \ \}\ while\ (0)}}
\DoxyCodeLine{00076\ }
\DoxyCodeLine{00077\ \textcolor{preprocessor}{\#define\ ANGLE\_LIMIT\_360\_TO\_180(val)\ \(\backslash\)}}
\DoxyCodeLine{00078\ \textcolor{preprocessor}{\ \ \ \ do\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00079\ \textcolor{preprocessor}{\ \ \ \ \{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00080\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ if\ ((val)\ >\ 180)\ \ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00081\ \textcolor{preprocessor}{\ \ \ \ \ \ \ \ \ \ \ \ (val)\ -\/=\ 360;\ \ \ \ \ \ \ \ \ \ \ \(\backslash\)}}
\DoxyCodeLine{00082\ \textcolor{preprocessor}{\ \ \ \ \}\ while\ (0)}}
\DoxyCodeLine{00083\ }
\DoxyCodeLine{00084\ \textcolor{preprocessor}{\#define\ VAL\_MIN(a,\ b)\ ((a)\ <\ (b)\ ?\ (a)\ :\ (b))}}
\DoxyCodeLine{00085\ \textcolor{preprocessor}{\#define\ VAL\_MAX(a,\ b)\ ((a)\ >\ (b)\ ?\ (a)\ :\ (b))}}
\DoxyCodeLine{00086\ }
\DoxyCodeLine{00093\ \textcolor{keywordtype}{void}\ *\mbox{\hyperlink{user__lib_8h_a31afb956339abf0230d4314c847dd971}{zmalloc}}(\textcolor{keywordtype}{size\_t}\ size);}
\DoxyCodeLine{00094\ }
\DoxyCodeLine{00095\ \textcolor{comment}{//\ {\ucr}{\ucr}{\ucr}ٿ{\ucr}{\ucr}{\ucr}}}
\DoxyCodeLine{00096\ \textcolor{keywordtype}{float}\ Sqrt(\textcolor{keywordtype}{float}\ x);}
\DoxyCodeLine{00097\ \textcolor{comment}{//\ {\ucr}{\ucr}{\ucr}{\ucr}{\ucr}{\ucr}{\ucr}{\ucr}}}
\DoxyCodeLine{00098\ \textcolor{keywordtype}{float}\ abs\_limit(\textcolor{keywordtype}{float}\ num,\ \textcolor{keywordtype}{float}\ Limit);}
\DoxyCodeLine{00099\ \textcolor{comment}{//\ {\ucr}жϷ{\ucr}{\ucr}{\ucr}λ}}
\DoxyCodeLine{00100\ \textcolor{keywordtype}{float}\ sign(\textcolor{keywordtype}{float}\ value);}
\DoxyCodeLine{00101\ \textcolor{comment}{//\ {\ucr}{\ucr}{\ucr}{\ucr}{\ucr}{\ucr}{\ucr}{\ucr}}}
\DoxyCodeLine{00102\ \textcolor{keywordtype}{float}\ float\_deadband(\textcolor{keywordtype}{float}\ Value,\ \textcolor{keywordtype}{float}\ minValue,\ \textcolor{keywordtype}{float}\ maxValue);}
\DoxyCodeLine{00103\ \textcolor{comment}{//\ {\ucr}޷{\ucr}{\ucr}{\ucr}{\ucr}{\ucr}}}
\DoxyCodeLine{00104\ \textcolor{keywordtype}{float}\ float\_constrain(\textcolor{keywordtype}{float}\ Value,\ \textcolor{keywordtype}{float}\ minValue,\ \textcolor{keywordtype}{float}\ maxValue);}
\DoxyCodeLine{00105\ \textcolor{comment}{//\ {\ucr}޷{\ucr}{\ucr}{\ucr}{\ucr}{\ucr}}}
\DoxyCodeLine{00106\ int16\_t\ int16\_constrain(int16\_t\ Value,\ int16\_t\ minValue,\ int16\_t\ maxValue);}
\DoxyCodeLine{00107\ \textcolor{comment}{//\ ѭ{\ucr}{\ucr}{\ucr}޷{\ucr}{\ucr}{\ucr}{\ucr}{\ucr}}}
\DoxyCodeLine{00108\ \textcolor{keywordtype}{float}\ loop\_float\_constrain(\textcolor{keywordtype}{float}\ Input,\ \textcolor{keywordtype}{float}\ minValue,\ \textcolor{keywordtype}{float}\ maxValue);}
\DoxyCodeLine{00109\ \textcolor{comment}{//\ {\ucr}Ƕ{\ucr}\ {\ucr}{\ucr}{\ucr}޷{\ucr}\ 180\ \string~\ -\/180}}
\DoxyCodeLine{00110\ \textcolor{keywordtype}{float}\ theta\_format(\textcolor{keywordtype}{float}\ Ang);}
\DoxyCodeLine{00111\ }
\DoxyCodeLine{00112\ \textcolor{keywordtype}{int}\ float\_rounding(\textcolor{keywordtype}{float}\ raw);}
\DoxyCodeLine{00113\ }
\DoxyCodeLine{00114\ \textcolor{keywordtype}{float}\ *Norm3d(\textcolor{keywordtype}{float}\ *v);}
\DoxyCodeLine{00115\ }
\DoxyCodeLine{00116\ \textcolor{keywordtype}{float}\ NormOf3d(\textcolor{keywordtype}{float}\ *v);}
\DoxyCodeLine{00117\ }
\DoxyCodeLine{00118\ \textcolor{keywordtype}{void}\ Cross3d(\textcolor{keywordtype}{float}\ *v1,\ \textcolor{keywordtype}{float}\ *v2,\ \textcolor{keywordtype}{float}\ *res);}
\DoxyCodeLine{00119\ }
\DoxyCodeLine{00120\ \textcolor{keywordtype}{float}\ Dot3d(\textcolor{keywordtype}{float}\ *v1,\ \textcolor{keywordtype}{float}\ *v2);}
\DoxyCodeLine{00121\ }
\DoxyCodeLine{00122\ \textcolor{keywordtype}{float}\ AverageFilter(\textcolor{keywordtype}{float}\ new\_data,\ \textcolor{keywordtype}{float}\ *buf,\ uint8\_t\ len);}
\DoxyCodeLine{00123\ }
\DoxyCodeLine{00124\ \textcolor{preprocessor}{\#define\ rad\_format(Ang)\ loop\_float\_constrain((Ang),\ -\/PI,\ PI)}}
\DoxyCodeLine{00125\ }
\DoxyCodeLine{00126\ \textcolor{preprocessor}{\#endif}}

\end{DoxyCode}
